const path = require('path')

const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    entry: {
        main: ['./script/main.js', './script/b.js'],
        a: ['./script/a.js']
    },
    output: {
        path: path.resolve(__dirname, "dist"),
        filename: "js/[name]-[chunkhash].js"
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: './index.html',
            inject: 'head', //打包的js嵌入到html的标签可以是head,body
            minify: {
                // collapseWhitespace: true, //删除空格
                removeComments: true, //删除注释
            }
        })
    ],
    module: {
        rules: [{
            test: /\.css$/,
            use: ['style-loader', 'css-loader']
        }, {
            test: /\.(png|jpg|gif|jpeg|svg)$/i,
            use: [{
                loader: 'file-loader',
                options: {
                    name: 'assets/[name]-[hash:5].[ext]?[hash]'
                }
            }]
        }]
    },
}